# Maintainer: David Runge <dvzrv@archlinux.org>
# Maintainer: Daurnimator <daurnimator@archlinux.org>

pkgname=waylock
pkgver=0.6.3
pkgrel=1
pkgdesc="A simple screenlocker for wayland compositors"
arch=(loong64 x86_64)
url="https://github.com/ifreund/waylock"
license=(ISC)
depends=(
  glibc
)
makedepends=(
  libxkbcommon
  pam
  scdoc
  wayland
  wayland-protocols
  zig
)
source=($url/releases/download/v$pkgver/$pkgname-$pkgver.tar.gz{,.sig})
sha512sums=('783190a0bb225dc6e1483efd95ae9222f8bfd2a208d8a7fb408637068a5258b4333b083b5955af0b6f034e26b3a4678c822353211689d4194e2e503c4858fa0c'
            'SKIP')
b2sums=('dba424a457c940df7931de8052e0e9dcbf88abefdaa0035831873bcbed1f721a5473d70d84a98adc8f5505c9133f7b806238b47bb98a37bba0b8b712591af3fb'
        'SKIP')
validpgpkeys=('5FBDF84DD2278DB2B8AD8A5286DED400DDFD7A11') # Isaac Freund <mail@isaacfreund.com>

build() {
  local zig_options=(
    -Dcpu=baseline
    -Dpie
    -Dtarget=native-linux.5.15-gnu
    --prefix /usr
    --search-prefix /usr
    --verbose
  )

  cd $pkgname-$pkgver
  DESTDIR=build zig build "${zig_options[@]}"
}

package() {
  depends+=(
    libxkbcommon libxkbcommon.so
    pam libpam.so
    wayland libwayland-client.so
  )

  cd $pkgname-$pkgver

  mv -v build/* "$pkgdir"

  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 README.md -t "$pkgdir/usr/share/doc/$pkgname/"
}
